package com.internal.Login.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

public class LoginContent extends Composite {

	private final VerticalPanel mainPanel = new VerticalPanel();
	private final HorizontalPanel usernamePnl = new HorizontalPanel();
	private final HorizontalPanel pwPnl = new HorizontalPanel();
	private final TextBox usernameTxt;
	private final PasswordTextBox pwTxt;
	private final Button loginBtn;
	private final LoginClientUtil loginUtil ;

	public LoginContent() {
		loginUtil = new LoginClientUtil(this);
		mainPanel.setStyleName("login-center-pnl-ar ");
		mainPanel.setSpacing(10);

		Label usernameLbl = new Label("اسم المستـخدم:");
		usernameLbl.setStyleName("login-label");

		usernameTxt = new TextBox();
		usernameTxt.setStyleName("login-text");

		HTML pwLbl = new HTML("كلمــة السر :");
		pwLbl.setStyleName("login-label");

		pwTxt = new PasswordTextBox();
		pwTxt.setStyleName("login-text");
		
		loginBtn = new Button("دخــــــول");
		loginBtn.setStyleName("login-button");
		
		loginBtn.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				loginUtil.login(usernameTxt.getValue(),
						pwTxt.getValue());
			}
		});
		
		HTML lostPW =new HTML("فقدت كلمة المرور؟");
		lostPW.setStyleName("edit-style");
		
		lostPW.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				
				DialogBox sendPWDial = loginUtil.showForgetPWDial("استعادة كلمة السر", " : الايمـــــــيل " );
				sendPWDial.setSize("250px", "140px");
				sendPWDial.setGlassEnabled(true);
				sendPWDial.setAnimationEnabled(true);
				sendPWDial.center();
				sendPWDial.show();
				
			}
		});


		usernamePnl.add(usernameLbl);
		usernamePnl.add(usernameTxt);

		pwPnl.add(pwLbl);
		pwPnl.add(pwTxt);
		
		mainPanel.add(usernamePnl);
		mainPanel.add(pwPnl);
		mainPanel.add(loginBtn);
		mainPanel.add(lostPW);
		
		initWidget(mainPanel);
	}
}
